package com.lyw.controller;

import com.lyw.entity.Student;
import com.lyw.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class StudentController {

  @Autowired
  StudentMapper studentMapper;

  @ResponseBody
  @GetMapping("/searchStudent")
  public Student searchStudent(String name) {
    return studentMapper.searchStudent(name);
  }

  @ResponseBody
  @PostMapping("/insertStudent")
  public String add(Student student) {
    Integer integer = studentMapper.insertStudent(student);
    if (integer != null)
      return "添加成功！";
    return "添加失败！";
  }
}
